package practice3;

import org.junit.Test;
import static org.junit.Assert.*;

public class ExerciseTest {
    @Test
    public void testGenerateAdditions() {
        Exercise exercise = new Exercise(50);
        exercise.generateAdditions(100);
        assertEquals(50, exercise.getArithmetics().size());
        // 验证加法和≤100
        for (Arithmetic a : exercise.getArithmetics()) {
            assertEquals('+', a.getOperator());
            assertTrue(a.getNum1() + a.getNum2() <= 100);
        }
    }

    @Test
    public void testGenerateSubtractions() {
        Exercise exercise = new Exercise(50);
        exercise.generateSubtractions(100);
        assertEquals(50, exercise.getArithmetics().size());
        // 验证减法差≥0
        for (Arithmetic a : exercise.getArithmetics()) {
            assertEquals('-', a.getOperator());
            assertTrue(a.getNum1() - a.getNum2() >= 0);
        }
    }
}